$(function () {
    $(".single_build").on('click', single_build);
});

function single_build(event) {
    let index = $(this).data("value");
    let task_number = $("#task_number").val();
    let sysid = $("#sysid_" + index).val();
    let gittag = $("#gittag_" + index).val();
    let opser = $("#opser_" + index).val();
    let memo = $("#memo_" + index).val();
    let exception = $("#exception_" + index).val();
    let url = "/build/pre_single_build";
    let data_param = {
        "task_number": task_number,
        "sysid": sysid,
        "gittag": gittag,
        "opser": opser,
        "memo": memo,
        "exception": exception
    };
    ajax_build_job(url, data_param, gittag, $(this));
}

function ajax_build_job(url, data_param, gittag, button_instance) {
    $.post(
        url,
        data_param,
        function (data) {
            if ((data['code']) == "200") {
                alert(gittag + " build 成功!")
                button_instance.attr("disabled", "true");
            }
            if ((data['code']) == "999") {
                alert(gittag + " build 失败!")
            }

        },
        "json"
    );

}